package com.mb.mp.service.impl;

import com.mb.mp.dao.MpCompanyInfoDOMapper;
import com.mb.mp.domain.MpCompanyInfoDO;
import com.mb.mp.service.ICompanyInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 公司信息service 实现
 * @author
 * @create 2018-09-19 下午2:31
 **/
@Service("companyInfoService")
public class CompanyInfoServiceImpl implements ICompanyInfoService {
    @Autowired
    MpCompanyInfoDOMapper companyInfoDOMapper;

    @Override
    public MpCompanyInfoDO getInfo() {
        return companyInfoDOMapper.getInfo();
    }

    @Override
    public void save(MpCompanyInfoDO companyInfo) {
        MpCompanyInfoDO companyInfoDO = companyInfoDOMapper.getInfo();
        if(companyInfoDO != null){
            companyInfoDO.setCompanyName(companyInfo.getCompanyName());
            companyInfoDO.setCompanyTel(companyInfo.getCompanyTel());
            companyInfoDO.setCompanyDetail(companyInfo.getCompanyDetail());
            companyInfoDOMapper.updateByPrimaryKeySelective(companyInfoDO);
        }else{
            companyInfoDOMapper.insertSelective(companyInfo);
        }
    }
}
